from selenium.webdriver.common.by import By

from utils.page import Page


class PageSystemOperateLog(Page):
    '''
    系统操作日志类:提供在系统操作日志页面的各个操作
    '''
    def __init__(self):
        super(PageSystemOperateLog, self).__init__()
        self.page = Page()
        self.url = 'http://120.53.243.26:8009/#/systemLog'
        self.loc_input = (By.CSS_SELECTOR, '#basicSearch > div.search_content > div > div > input')
        self.loc_search = (By.CSS_SELECTOR, '#basicSearch > div.search_btn > button.el-button.el-button--primary.el-button--medium')
        self.loc_log_record = (By.CSS_SELECTOR, 'tbody > tr >td:nth-child(1) > div')

    def input_username(self, username):
        '''
        在输入框中输入账号
        :return:
        '''
        self.input(username, *(self.loc_input))

    def search(self):
        '''
        点击搜索按钮
        :return:
        '''
        self.page.click(*(self.loc_search))

    def do_search(self, username):
        '''
        输入账号并点击搜索
        :return:
        '''
        self.input_username(username)
        self.search()

    def get_search_result(self):
        '''
        将搜索结果返回成一个列表
        :return:
        '''
        return self.page.finds(*(self.loc_log_record))
